package com.livedocumentation.client.web.menu;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.livedocumentation.client.GWTEntryPoint;
import com.livedocumentation.client.model.ProjectClass;
import com.livedocumentation.client.model.Feature;
import com.livedocumentation.client.web.MainPage;
import com.livedocumentation.client.web.description.FeaturePanel;

/**
 * 
 * @UserInterface
 */
public class FeaturesList extends VerticalPanel {

	public FeaturesList() {

		this.setSpacing(5);

		for (final ProjectClass entry : GWTEntryPoint.sourceFeatures) {

			if (entry.getFeatureType() != null
					&& entry.getFeatureType().equals(
							Feature.FEATURE_TYPE)) {

				String name = "<a href='#'><B>" + entry.getFeatureName()
						+ "</B></a><br>";

				HTML html = new HTML(name);

				html.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent sender) {

						Menu.untoggleLinks();

						MainPage.documentationPanel.clear();

						MainPage.documentationPanel
								.add(new FeaturePanel(entry));
					}
				});

				this.add(html);
			}
		}
	}
}